home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Bug in FW_CInterest?
- Sent: 6/26/96 1:01 PM
- Received: 6/26/96 1:21 PM
- From: Laurent Delamare, laurentd@apple.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- >The operator == definition of FW_CInterest in FWIntere.cpp, is giving me
- >problems. Seems it always returns TRUE. Perhaps the return condition does
- >not get fully evaluated due to precedence. Surrounding the return
- >condition with parentheses may solve the problem.
- >
- > return (fNotifier == other.fNotifier && fMessage == other.fMessage);
- >...
- >
- >I don't seem to be able to add more than one interest to the list of a
- >particular class object I'm writing. Any idea how I can get around the bug
- >easily?
-
- Did you get a chance to try your solution? (i.e. rebuild the Foundation
- library with your change)
-
- I would need a test case to check your problem because I can't reproduce
- it here. For instance, in ODF Form, I added this in
- CFormView::PostCreateViewFromStream()
-
- frame->AddNotifier(listbox, FW_kListBoxDoubleClickMsg); // -> current
- code
- frame->AddNotifier(listbox, 1); // -> my
- addition
-
- and I checked with the debugger that the interest was being added
- correctly
- to the list of the frame receiver (because it's a different msg)
-
-
- >
- >I also noticed the following comment in FW_MNotifier::Notify()
- > while (pair)
- > {
- > // Get the next pair before doing any action in case the object is
- >destroyed
- > // in the middle (for instance: OK button closing a dialog)
- > // [LSD] Warning: still dangerous in case the notifier has more than
- >1 interest
- >
- >This appears to be true. Have you worked out a solution?
- >
- >
- >Arni
- >
-
- I did. I had to fix that bug recently to make something else work.
- The fix is to patch your FWNotifr.cpp file with this new destructor
- and rebuild the foundation library:
-
- //----------------------------------------------------------------------
- // FW_MNotifier::~FW_MNotifier
- //-----------------------------------------------------------------------
-
- FW_MNotifier::~FW_MNotifier()
- {
- // Notify the receivers that this notifier is being deleted
-
- FW_TOrderedCollectionIterator<FW_SPrivInterestReceiver>
- ite(&fInterestList);
- FW_SPrivInterestReceiver* pair = ite.First();
-
- if (pair == 0)
- return;
-
- // First we build the list of all receivers connected to this notifier
- FW_SOMEnvironment ev;
- FW_CNotification notifierDeleted(FW_CInterest(this,
- FW_kNotifierDeletedMsg));
- FW_TOrderedCollection<FW_MReceiver> receiverList;
-
- while (pair)
- {
- if (!receiverList.Contains(pair->fReceiver))
- receiverList.AddLast(pair->fReceiver);
-
- pair = ite.Next();
- }
-
- // Now we can send them the notification without danger, even if some are
- // deleted as the result
- FW_TOrderedCollectionIterator<FW_MReceiver> ite2(&receiverList);
- for (FW_MReceiver* receiver = ite2.First(); ite2.IsNotComplete();
- receiver = ite2.Next())
- {
- receiver->HandleNotification(ev, notifierDeleted);
- }
-
- // ----- Delete all left over interest pair
- while ((pair = fInterestList.First()) != NULL)
- {
- // RemoveInterest will call RemoveReceiver
- pair->fReceiver->RemoveInterest(*pair->fInterest);
- }
- }
-
-
-
- ______________________________________________________________________
- Laurent Delamare laurentd@apple.com
- ODF Team http://www.devtools.apple.com/odf/
- Apple Computer, Inc. http://www.opendoc.apple.com/
-